import { observable, action } from 'mobx'
import axios from '../../../common/request'
import  notificationWithIcon from '../../common/notificationWithIcon';

class HasApplyListStore {
    @observable page={
        currentPage:1,
        pageSize:10
    }
    @observable total
    @observable applies=[]
    actions = {
        getApplies: action((param)=>{
            axios.get('/api/activity/apply/people/'+param+"?pageNumber="+this.page.currentPage+"&pageSize="+this.page.pageSize)
                .then((response)=> {
                    if(response.data.status.code===1) {
                        this.applies=response.data.result.data
                        this.total=response.data.result.total
                    }
                    else{
                        notificationWithIcon('error',response.data.status.message,"")
                    }
                })
                .catch(function (error) {
                    notificationWithIcon('error',"获取报名列表失败",error.response)
                    console.log(error);
                });
        }),
        setCurrentPage: action((param,page) => {
            this.page={
                currentPage:page,
                pageSize:this.page.pageSize
            }
            this.actions.getApplies(param)
        }),
    }
}

export default new HasApplyListStore()